package com.qdlc.p2p.biz.executer.impl;

import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

import com.qdlc.p2p.biz.executer.BaseExecuter;
import com.qdlc.p2p.common.constant.Global;
import com.qdlc.p2p.common.constant.LogTplNid;
import com.qdlc.p2p.dal.dto.OperationLog;
import com.qdlc.p2p.dal.util.SystemConfigs;

/**
 * 申请vip
 *
 * @author zxc
 */
@Service
@Scope(value = ConfigurableBeanFactory.SCOPE_PROTOTYPE)
public class ApplyVipExecuter extends BaseExecuter {

    @Override
    public void handleAccountWithLog() {
        // 申请vip，冻结资金
        Global.setTransfer(LogTplNid.LOG_TPL_KEY, LogTplNid.VIP_FEE);
        Global.setTransfer("web_url", WEB_URL);
        accountService.freeze(super.user.getUserId(), SystemConfigs.ADMIN_ID, super.money);
    }

    @Override
    public void addOperateLog() {
        OperationLog operationLog = new OperationLog(user, operator, LogTplNid.VIP_FREEZE);
        operationLog.setOperationResult("用户名为" + user.getUserName() + "用户，申请vip成功，冻结资金" + money + " 元，等待审核 ");
        operationLogDao.save(operationLog);
    }
}
